package edu.ustb.gateway.service;

import edu.ustb.gateway.service.impl.GatewayServiceImpl;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.MessageChannel;

import javax.annotation.Resource;

/**
 * @author ShiZhe
 * @create 2021-04-20 22:46
 * 定义消息的推送管道
 */
@EnableBinding(Source.class)
public class GatewayService implements GatewayServiceImpl {
    @Resource
    private MessageChannel output;

    @Override
    public void send(String json) {
        //发送消息
        output.send(MessageBuilder.withPayload(json).build());
        System.out.println("==> json:" + json);
    }
}
